<template>
  <div>
    <van-nav-bar title="我的关注" left-arrow @click-left="$router.back()" />
    <van-list
      v-model="isloading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <van-cell v-for="(item, index) in list" :key="index">
        <div class="userinfo">
          <van-image round fit="cover" :src="item.photo" />

          <div class="title">
            <div>{{ item.name }}</div>
            <div class="time">粉丝数：{{ item.fans_count }}人</div>
          </div>

          <van-button type="primary" round size="samll" plain color="#d0355d"
            >取消关注</van-button
          >
        </div>
      </van-cell>
    </van-list>
  </div>
</template>

<script>
import { userFollowingsAPI } from '@/api/user'
export default {
  data() {
    return {
      isloading: false,
      finished: false,
      list: [],
      page: 1
    }
  },
  methods: {
    async onLoad() {
      const res = await userFollowingsAPI({
        page: this.page
      })
      this.page++
      this.isloading = false
      this.list.push(...res.data.results)
      if (this.list.length <= res.data.total_count) {
        this.finished = true
      }
    }
  }
}
</script>

<style lang="less" scoped>
.userinfo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .van-image {
    width: 80px;
    height: 80px;
  }
  .title {
    flex: 1;
    margin-left: 10px;
    .time {
      font-size: 10px;
      color: gray;
    }
  }
  .van-button {
    width: 60px;
    height: 30px;
    .van-button__text {
      font-size: 12px;
    }
  }
}
</style>
